<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>车辆调度管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function vehicleChange(licno){
			var  officeid = '${tRealscheVehis.office.id}'
			//var licenseno = '${tRealscheVehis.licno}';
			url = "${ctx}/schedef/tSchedef/ajaxList";
			 $.ajax({
		          dataType: 'json',
		            url:url,
		            data:{officeids:officeid,licno:licno},
		            type: 'POST',
		            success: function(data) {
		            	 var obj = eval(data);
		            	 console.log(obj);
		            	 $(seats).val(obj[0].seats);
		            	 $(brandname).val(obj[0].brand);
		            	/*  $(schename).val(obj[0].schename); */
		            	/*  $(departdate).val(obj[0].departdate);*/
		            	 $(vehiclename).val(obj[0].vehiclename); 
		            	 /* var html = '';
		            	 jQuery(licno).html('');
		            	  $.each(obj, function (i, item) {
		            		  var select = licenseno==item.licenseno?"selected=selected":"";
		            		 //jQuery(licno).append("<option value="+ item.licenseno+">"+ item.licenseno+"</option>");
		            		  //var select = checkLicenseno(item.licenseno)?"selected=selected":"";
		            		  html+="<option value='"+ item.licenseno+"' "+select+">"+ item.licenseno+"</option>";
		            		 }); 
		            	  jQuery(licno).html(html); */
		            },
		            error: function() {
		            		 alert("数据有误");
		            }
		        });     
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/vehi/tRealscheVehis/">车辆调度列表</a></li>
		<li class="active"><a href="${ctx}/vehi/tRealscheVehis/form?id=${tRealscheVehis.id}">车辆调度<shiro:hasPermission name="vehi:tRealscheVehis:edit">${not empty tRealscheVehis.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="vehi:tRealscheVehis:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="tRealscheVehis" action="${ctx}/vehi/tRealscheVehis/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">客运公司：</label>
			<div class="controls">
				<%-- <sys:treeselect id="office" name="office.id" value="${tRealscheVehis.office.id}" labelName="office.name" labelValue="${tRealscheVehis.office.name}"
					title="部门" url="/sys/office/treeData?type=2" cssClass="" allowClear="true" notAllowSelectParent="true"/> --%>
					<input type="text"  id="office.id" name="office.id" value="${tRealscheVehis.office.name}" readonly="readonly" class="span4 ">
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">班次名称：</label>
			<div class="controls">
				<form:input path="schename" htmlEscape="false" maxlength="50" class="span4 required" readonly="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发车日期：</label>
			<div class="controls">
				<input name="departdate" type="text" readonly="readonly"
					maxlength="20" class="span4 Wdate "
					value="<fmt:formatDate value="${tRealsche.departdate}" pattern="yyyy-MM-dd"/>"/>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">车牌号：</label>
			<div class="controls">
				<%-- <form:input path="licno" htmlEscape="false" maxlength="20" class="span4 "/> --%>
				<select id="licno" name="licno" class="span4" onchange="vehicleChange(this.options[this.options.selectedIndex].value)" >
				<c:forEach items="${vehiclenameList}" var="vehicle">
						<option value="${vehicle.licenseno}"
							<c:if test="${vehicle.licenseno eq tRealscheVehis.licno}">selected="selected"</c:if>>
							${vehicle.licenseno}</option>
					</c:forEach>
					</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">车辆型号：</label>
			<div class="controls">
				 <form:input path="vehiclename" htmlEscape="false" maxlength="200" class="span4 required" readonly="true"/> 
				<%-- <select id="vehiclename" name="vehiclename" class="input-xxlarges" onchange="vehicleChange(this.options[this.options.selectedIndex].value)">
				<c:forEach items="${vehiclenameList}" var="vehicle">
						<option value="${vehicle.vehiclename}"
							<c:if test="${vehicle.vehiclename eq tRealscheVehis.vehiclename}">selected="selected"</c:if>>
							${vehicle.vehiclename}</option>
					</c:forEach>
					</select> --%>
				<!-- <span class="help-inline"><font color="red">*</font> </span> -->
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">车辆品牌：</label>
			<div class="controls">
				<form:input path="brandname" htmlEscape="false" maxlength="50" class="span4 required" readonly="true"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">座位数：</label>
			<div class="controls">
				<form:input path="seats" htmlEscape="false" class="span4 required" readonly="true"/>
			</div>
		</div>
<%-- 		<div class="control-group">
			<label class="control-label">selloutseats：</label>
			<div class="controls">
				<form:input path="selloutseats" htmlEscape="false" class="span4 "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">lockedseats：</label>
			<div class="controls">
				<form:input path="lockedseats" htmlEscape="false" class="span4 "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">vehistatus：</label>
			<div class="controls">
				<form:input path="vehistatus" htmlEscape="false" maxlength="1" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">realdepart：</label>
			<div class="controls">
				<input name="realdepart" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${tRealscheVehis.realdepart}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">drvssysid：</label>
			<div class="controls">
				<form:input path="drvssysid" htmlEscape="false" class="input-xlarge "/>
			</div>
		</div>
 --%>		<div class="form-actions">
			<shiro:hasPermission name="vehi:tRealscheVehis:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>